<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('permissions', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('parent_id')->default(0)->comment('父级ID');
            $table->tinyInteger('type')->comment('类型:1菜单 2按钮');
            $table->string('title', 50)->comment('权限标题');
            $table->string('icon')->nullable()->comment('菜单图标');
            $table->string('name')->nullable()->comment('路由名称');
            $table->string('active')->nullable()->comment('激活路由');
            $table->string('redirect')->nullable()->comment('重定向地址');
            $table->string('slug')->nullable()->comment('权限标识');
            $table->integer('sort')->default(0)->comment('排序权重');
            $table->tinyInteger('status')->default(1)->comment('权限状态 0=禁用 1=启用');
            $table->boolean('is_show')->default(true)->comment('是否显示');
            $table->timestamps();
            $table->comment('权限表');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('permissions');
    }
};
